// pages/category/category.js
const app = getApp()
var host = app.globalData.host;
Page({

    /**
     * 页面的初始数据
     */
    data: {
        currentTab: 0,
    },
    onLoad: function(options) {
        var page = this;
        this.loadCategory();

    },
    loadCategory: function() {
        var page = this;
        wx.request({
            url: host + '/api/category/getCategoryList',
            method: 'GET',
            data: {},
            header: {
                'Content-Type': 'application/json'
            },
            success: function(res) {
                console.log(res);
                var code = res.data.code;
                var category = res.data.data;
                if (code = '0000') {
                    var category = res.data.data;
                    page.setData({ category: category })
                }
            }
        })
    },
    // 实现切换导航栏
    switchNav: function(e) {
        console.log(e)
        var page = this;
        var id = e.target.id;
        if (this.data.currentTab == id) {
            return false;
        } else {
            page.setData({ currentTab: id });
        }
        page.setData({ currentTab: id });

    },
    tab: function(e) {
        this.setData({
                currentTab: e.detail.current
            })
            // console.log(this.data.currentTab)
    },
    methods: {

    }
})